import request from './request';

// 获取产品列表
export function getProductList(params) {
  return request({
    url: '/api/omm/products/',
    method: 'get',
    params
  });
}

// 获取单个产品
export function getProduct(id) {
  return request({
    url: `/api/omm/products/${id}/`,
    method: 'get'
  });
}

// 新增产品
export function createProduct(data) {
  return request({
    url: '/api/omm/products/',
    method: 'post',
    data
  });
}

// 更新产品
export function updateProduct(id, data) {
  return request({
    url: `/api/omm/products/${id}/`,
    method: 'put',
    data
  });
}

// 删除产品
export function deleteProduct(id) {
  return request({
    url: `/api/omm/products/${id}/`,
    method: 'delete'
  });
}

// 批量删除产品
export function batchDeleteProducts(ids) {
  return request({
    url: '/api/omm/products/batch_delete/',
    method: 'post',
    data: { ids }
  });
}

// 导出产品数据
export function exportProducts(params) {
  return request({
    url: '/api/omm/products/export/',
    method: 'get',
    params,
    responseType: 'blob'
  });
}

// 获取导入模板
export function getImportTemplate() {
  return request({
    url: '/api/omm/products/import_template/',
    method: 'get',
    responseType: 'blob'
  });
}

// 导入产品数据
export function importProducts(data) {
  return request({
    url: '/api/omm/products/import_data/',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
} 